<template>
	<view class="detailView">
		<view class="container">
			<view class="info-box">
				<view class="course-title">{{info.name}}</view>
				<view class="info-list">
					<view class="info-item" v-for="(item,index) in infoRef">
						<view class="info-item__key">{{item.title}}</view>
						<view class="info-item__val">{{info[item.key]}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				info: '',
				infoRef: [{
						title: "周数",
						key: "rawWeeks"
					},
					{
						title: "节数",
						key: "rawSection"
					},
					{
						title: "地点",
						key: "address"
					},
					{
						title: "老师",
						key: "teacher"
					},
					{
						title: "学分",
						key: "credit"
					},
					{
						title: "类型",
						key: "category"
					},
					{
						title: "考查",
						key: "method"
					},
				]
			}
		},
		onLoad(options) {
			// console.log(options);
			this.info = options.info || ''
			if (this.info == '') {
				uni.showToast({
					title: '页面不存在',
					icon: 'none'
				})
				setTimeout(() => {
					uni.navigateBack({
						delta: 1
					})
				}, 1500)
				return
			}
			this.info = JSON.parse(options.info)
			this.info.rawSection = '周' + this.info.rawSection
			console.log(this.info);

		},
		methods: {

		}
	}
</script>

<style lang="scss" scoped>
	.detailView {
		page {
			background-color: #FAFAFA;
		}

		.container {

			.info-box {
				background-color: #fff;
				padding: 30rpx 30rpx 0;

				.course-title {
					font-size: 32rpx;
					color: #333333;
				}

				.info-list {
					margin-top: 10rpx;

					.info-item {
						display: flex;
						align-items: center;
						padding: 24rpx 0;

						&:not(:last-child) {
							border-bottom: 1rpx solid rgba(243, 243, 243, 0.82);
						}

						.info-item__key {
							color: $main-color-primary;
							margin-right: 40rpx;
						}

						.info-item__val {
							color: #666666;
						}
					}


				}
			}
		}
	}
</style>